<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>

<s:layout-render name="/layout_admin.jsp">
    <s:layout-component name="content">
        <s:useActionBean beanclass="cz.muni.fi.pa165.travelagency.web.OrderActionBean" var="actionBean"/>
        <s:link beanclass="cz.muni.fi.pa165.travelagency.web.OrderActionBean" event="all"><f:message key="order.show.all" /></s:link>
        <c:if test="${not empty actionBean.unpaidOrders}">
            <h3><f:message key="order.unpaidOrders" /></h3>
            <table>
                <tr>
                    <th><f:message key="order.id"/></th>
                    <th><f:message key="order.customer"/></th>
                    <th><f:message key="order.orderedPackageTour"/></th>
                    <th><f:message key="order.orderedTours"/></th>
                    <th><f:message key="order.created"/></th>
                    <th><f:message key="order.numberOfPersons"/></th>
                    <th><f:message key="order.paid"/></th>
                    <th><f:message key="order.price"/></th>
                    <th><f:message key="tour.show.legend"/></th>
                    <th><f:message key="order.action.delete"/></th>
                    <th><f:message key="order.action.edit"/></th>
                </tr>
                <c:forEach items="${actionBean.unpaidOrders}" var="order">
                    <tr>
                        <td>${order.id}</td>
                        <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.CustomerActionBean" event="edit-customer"><s:param name="customer.id" value="${order.customer.id}"/><c:out value="${order.customer.name}" /></s:link></td>
                        <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.PackageTourActionBean" event="edit"><s:param name="ptour.id" value="${order.orderedPackageTour.id}"/><c:out value="${order.orderedPackageTour.name}" /></s:link></td>
                        <td>
                            <c:if test="${not empty order.orderedTours}">
                                <c:forEach items="${order.orderedTours}" var="tour">
                                    <s:link beanclass="cz.muni.fi.pa165.travelagency.web.TourActionBean" event="edit"><s:param name="tour.id" value="${tour.id}"/><c:out value="${tour.name}"/></s:link>
                                </c:forEach>
                            </c:if>
                        </td>
                        <td><f:formatDate value="${order.created}" pattern="dd.MM.yyyy"/></td>
                        <td><c:out value="${order.numberOfPersons}"/></td>
                        <td><f:message key="${order.paid ? 'yes' : 'no'}"/></td>
                        <td><c:out value="${order.price}"/></td>
                        <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.OrderActionBean" event="choose-tours"><s:param name="order.id" value="${order.id}"/><f:message key="order.tours.empty" /></s:link></td>
                        <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.OrderActionBean" event="delete"><s:param name="order.id" value="${order.id}"/><f:message key="order.action.delete" /></s:link> </td>
                        <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.OrderActionBean" event="edit"><s:param name="order.id" value="${order.id}"/><f:message key="order.action.edit" /></s:link> </td>
                    </tr>
                </c:forEach>
            </table>
            <br>
        </c:if>
    </s:layout-component>
</s:layout-render>